#include <memory>
#include <type_traits>
#include <utility>

template<class T, class... Args>
std::unique_ptr<T> make_unique_helper(std::false_type, Args&&... args)
{
    return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}

template<class T, class... Args>
std::unique_ptr<T> make_unique_helper(std::true_type, Args&&... args)
{
    static_assert(std::extent<T>::value == 0,
        "make_unique<T[N]>() is forbidden, please use make_unique<T[]>().");
    typedef typename std::remove_extent<T>::type U;
    return std::unique_ptr<T>(new U[sizeof... (args)](std::forward<Args>(args)...));
}
//检测T的类型调用对应的make_unique_helper
template<class T, class... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{
    return make_unique_helper(std::is_array<T>(), std::forward<Args>(args)...);
}